package com.liwq.test.jol;

import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

import java.util.concurrent.TimeUnit;

/**
 * @author : liwq
 * @version : 1.0
 * @date : 2023/2/2
 **/

class Customer {

    private int id;
    private boolean aBoolean;

}

public class JolDemo {

    public static void main(String[] args) throws InterruptedException {
//        System.out.println(VM.current().details());
//        System.out.println(VM.current().objectAlignment());//对齐大小+


//        Object o = new Object();
//        System.out.println(ClassLayout.parseInstance(o).toPrintable());

        TimeUnit.SECONDS.sleep(5);
        Customer customer = new Customer();
        System.out.println(customer.hashCode());
        System.out.println(Integer.toHexString(customer.hashCode()));
        System.out.println(Integer.toBinaryString(customer.hashCode()));

        System.out.println(ClassLayout.parseInstance(customer).toPrintable());

        synchronized (customer) {
            System.out.println("进来了");
            System.out.println("==========================");

            System.out.println(ClassLayout.parseInstance(customer).toPrintable());
        }


    }
}
